package leetcode.day_2020_11_16_11_22;

public class L_27 {
    public static void main(String[] args) {
        int[] arr = {0,1,2,2,3,0,4,2};
        System.out.println(removeElement(arr, 2));
    }

    public static int removeElement(int[] nums, int val) {
        int index = 0;
        for(int i=0; i<nums.length; i++) {
            if(nums[i] != val) {
                nums[index] = nums[i];
                index = index + 1;
            }
        }
        return index;
    }
}
